package threads;

class AThread implements Runnable {
	public void run() {
		Thread th = Thread.currentThread();
		for (int i = 0; i < 5; i++) {
			System.out.println("AThread:" + i + "\t" + th.getName() + "\t" + this);
		}
	}
}

class BThread implements Runnable {
	Thread th = null;

	BThread() {
		th = new Thread(this);
	}

	public void run() {
		Thread th = Thread.currentThread();
		for (int i = 100; i < 105; i++) {
			System.out.println("BThread:" + i + "\t" + th.getName() + "\t" + this);
		}
	}

	public void start() {
		th.start();
	}
}

class CThread implements Runnable {
	Thread th = null;

	CThread() {
		th = new Thread(this);
		th.start();
	}

	public void run() {
		Thread th = Thread.currentThread();
		for (int i = 990; i < 995; i++) {
			System.out.println("CThread:" + i + "\t" + th.getName() + "\t" + this);
		}
	}
}

class ThTest3 {
	public static void main(String args[]) {
		AThread ath = new AThread();
		ath.run();
		// ath.start();
		System.out.println("--------------------------");
		Thread th1 = new Thread(ath);
		Thread th2 = new Thread(ath);
		BThread bth = new BThread();
		new CThread();
		Runnable r1 = new Runnable() {
			public void run() {
				Thread th = Thread.currentThread();
				for (int i = 1110; i < 1115; i++) {
					System.out.println("Anonymous:" + i + "\t" + th.getName() + "\t" + this);
				}
			}
		};
		Thread th = new Thread(r1);
		th1.start();
		th2.start();
		bth.start();
	}
}
